Converting List<String> to String[] in Java
Posted
by Christian
on Stack Overflow
See other posts from Stack Overflow
or by Christian
Published on 2010-03-31T11:24:35Z
Indexed on
2010/03/31
11:33 UTC
Read the original article
Hit count: 478
java
How do I convert a list into an array? The following code returns an error.
public static void main(String[] args) {
List<String> strlist = new ArrayList<String>();
strlist.add("sdfs1");
strlist.add("sdfs2");
String[] strarray = (String[]) strlist.toArray();
System.out.println(strarray);
}
© Stack Overflow or respective owner